csharp 个ScriptableObject

ScriptableObject.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;



[System.Serializable]
public class TopScrollInfoText : ScriptableObject
{
  ScrollTextBehavior ScrollTextBehavior;

  [Header("Text Component Settings")]
  public Text Text;
  public string ScrollingText;
  [Space(15f)]
  [ColorUsage(true, true, 0, 1, 0, 1)]
  public Color Color;

  [Range(0f, 1f)]
  public float RChannel;
  [Range(0f, 1f)]
  public float GChannel;
  [Range(0f, 1f)]
  public float BChannel;
  [Space(15f)]

  [Header("Scroll Positions")]

  public RectTransform beginScroll;
  public RectTransform endScroll;
  public float speed;


 




 

  void OnEnable()
  {
    ScrollTextBehavior = FindObjectOfType<ScrollTextBehavior>();
    Color.a = 1f;
    
  }

  void Awake()
  {
   
   
   
  }

  void RandomChannelSet()
  {
    RChannel = Random.Range(0f, 1.0f);
    GChannel = Random.Range(0f, 1.0f);
    BChannel = Random.Range(0f, 1.0f);

  }

  public  IEnumerator ColorChange()
  {
    RandomChannelSet();
    bool goingUp = true;
    //  bool goindDown;
    while (true)
      {

        if (RChannel >= 1 && GChannel >= 1 || RChannel >= 1 && BChannel >= 1 || BChannel >= 1 && GChannel >= 1)
          {
            //RandomChannelSet();
            goingUp = false;

          } else if (RChannel <= 0 && GChannel <= 0 || RChannel <= 0 && BChannel <= 0 || BChannel <= 0 && GChannel <= 0)
          {
            // RandomChannelSet();
            goingUp = true;
          }

        if (goingUp == false)
          {
            while (RChannel >= 0f)
              {
                float x = Random.Range(0f, .09f);
                RChannel -= x;
                Color.r = RChannel;

                break;
              }
            while (GChannel >= 0f)
              {
                float x = Random.Range(0f, .09f);
                GChannel -= x;
                Color.g = GChannel;

                break;
              }
            while (BChannel >= 0f)
              {
                float x = Random.Range(0f, .09f);
                BChannel -= x;
                Color.b = BChannel;

                break;
              }

          }
        if (goingUp)
          {
            while (RChannel <= 1f)
              {
                RChannel += .03f;
                Color.r = RChannel;
           
                break;
              }
            while (GChannel <= 1f)
              {
                GChannel += .03f;
                Color.g = GChannel;
           
                break;
              }
            while (BChannel <= 1f)
              {
                BChannel += .03f;
                Color.b = BChannel;
            
                break;
              }
          }
        RChannel = Color.r;
        GChannel = Color.g;
        BChannel = Color.b;
        

        yield return new WaitForSeconds(.1f);
      }
    
  }

 
      
      
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;


public class ScrollTextBehavior : MonoBehaviour
{
  [TextArea(2, 2)]
  public  string LookFor = "Edit this component with the TopScrollInfoText Scriptable Object";

  TopScrollInfoText Info;
  Text thisText;
  RectTransform begin, end;

  float speed;

  public void SetUp()
  {
    Info = ScriptableObjectManager._instance.TopScrollInfoText;
    thisText = gameObject.GetComponentInChildren<Text>();
   

    begin = Info.beginScroll;
    end = Info.endScroll;
    thisText.rectTransform.localPosition = begin.localPosition;
     
    Debug.Log("SetUp Called");
  }

  void Start()
  {
   
    SetUp();
    StartCoroutine(Info.ColorChange());
 
  }

  void ScrollText()
  {
   
    Vector3 pos = new Vector3(end.localPosition.x, thisText.rectTransform.localPosition.y, 0);
    speed = Info.speed;
    thisText.color = Info.Color;
    thisText.text = Info.ScrollingText;
   
    if (thisText.rectTransform.localPosition.x > pos.x)
      {
        thisText.rectTransform.Translate(Vector3.left * speed * Time.fixedDeltaTime);
      } else
      {

        thisText.rectTransform.localPosition = begin.localPosition;

      }
  }


  void FixedUpdate()
  {
    ScrollText();

  }

 

}

csharp 光线投射

Raycast.cs

if (Input.GetMouseButton (0)) {
    		Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
			RaycastHit hit;

			if (Physics.Raycast (ray, out hit, 100)) {
				
				GameObject spawnPoint =  GameObject.CreatePrimitive (PrimitiveType.Cube);
				spawnPoint.name = "Spawn Point";
				Vector3 hitPos = Camera.main.WorldToViewportPoint (hit.transform.position);
				hitPos.x = 0.25f;
				hitPos.y = 0.25f;

				spawnPoint.transform.position = hit.transform.position;

				MeshFilter spawnMesh = spawnPoint.GetComponent<MeshFilter>();
				MeshRenderer spawnRend = spawnPoint.GetComponent<MeshRenderer> ();
				BoxCollider spawnCollider = spawnPoint.GetComponent<BoxCollider> ();
				spawnCollider.isTrigger = true;

				Debug.DrawLine (ray.origin, hit.point);
				Debug.Log (hit.point);
			}
			if (Physics.Linecast (transform1.position, transform2.position)) {

			Debug.Log ("Exploded from linecast");


			}
		}
		Debug.DrawRay (transform1.position, transform2.position);

csharp GetUserId

Example.cs
ValidationManager.GetUserId()

csharp StringWrapper.MidStrEx

Example.cs
StringWrapper.MidStrEx(ex.Message, "$", "$");

csharp List.Select.ToList

Example.cs
List<string> stateIds = stateItems.Select(p => p.STATE_ID).ToList();

csharp GridLayout.Combo.Dictionary

Example.cs
comboCURRENT_STATE = RadComboBoxExtension.CreateRadComboBoxWithSourceBind<BizCreditApply,
                HD.SVR.SDM.DataAccess.DataModels.SYS_DICTIONARY>(t => t.CURRENT_STATE, s => s.ITEM_NAME,
                s => s.ITEM_NAME, StyleList.radComboBox, null, validMaster);

gridLayout.AddField<BizCreditApply>(p => p.CURRENT_STATE, "", StyleList.dataNullable, comboCURRENT_STATE, "", 1, 1, validMaster);

csharp Invoke.Get

Example.cs
var configOper = await ctx.GetSysWfMasterByPageId(pageId).AsTask();

[Invoke]
public SYS_WF_MASTER_DEPLOY GetSysWfMasterDeployByPageId(string pageId)
  {
    ValidationManager.CheckUserValidation();
    return this.ObjectContext.SYS_WF_MASTER_DEPLOY.FirstOrDefault(p => p.PAGE_ID == pageId);
  }

csharp Invoke.SQL.Get

Example.cs
 var stateOper = await ctx.GetSysWfStateItemsByFlowID(this.CurrentFlow.FLOW_ID).AsTask();
 
 [Invoke]
        public SYS_WF_MASTER GetSysWfMasterByPageId(string pageId)
        {
            ValidationManager.CheckUserValidation();
            List<string> parameterNames = new List<string>(0);
            List<string> parameterValues = new List<string>(0);
            parameterNames.Add(DatabaseEnvir.paramSign + "PAGE_ID");
            parameterValues.Add(pageId);

            string strSQL = string.Format("SELECT * FROM SYS_WF_MASTER WHERE FLOW_ID IN (SELECT FLOW_ID FROM SYS_WF_MASTER_DEPLOY WHERE PAGE_ID = {0}PAGE_ID)", DatabaseEnvir.sqlSign);
            return this.ObjectContext.CreateQuery<SYS_WF_MASTER>(strSQL, parameterNames.ToArray(), parameterValues.ToArray()).FirstOrDefault();
        }

csharp SysDictionary.GetValue

Example.cs
var getOper = await HD.SL.SDM.DataAccess.Utilities.CacheEngine.GetCacheData<HD.SVR.SDM.DataAccess.DataModels.SYS_DICTIONARY>(
                CacheItem.SysDictionary.ToString(), p => p.ITEM_TYPE == "EXCEL_TEMPLATE" && p.ITEM_ID == "CUSTOMER_IMPORT");

csharp GridLayout.RadNumericUpDown

Example.cs
validMaster = new ValidationManager();
validMaster.RegisterValidation<RsItemCatalog>(p => p.CATALOG_SEQ, new RequirementValidation());

RadNumericUpDown numberTRANS_SEQ = RadNumericUpDownExtension.CreateNumericUpDownWithBind<RsItemCatalog>(
                                    p => p.CATALOG_SEQ, StyleList.rdNumericUpDown, validMaster);

gridLayout.AddField<RsItemCatalog>(p => p.CATALOG_SEQ, "", StyleList.dataNullable, numberTRANS_SEQ, "", 1, 1, validMaster);