示例#1
0
        private ISwitch findSwitch(string id)
        {
            ISwitch r = null;

            foreach (ISwitch isw in this.switches)
            {
                if (!string.IsNullOrEmpty(isw.id) && isw.id.Equals(id))
                {
                    r = isw;
                    break;
                }
            }
            return(r);
        }
示例#2
0
        public ISwitch addSwitch()
        {
            ISwitch iss = ScriptableObject.CreateInstance <ISwitch>();

            this.switches.Add(iss);
        #if UNITY_EDITOR
            if (Application.isEditor && !Application.isPlaying &&
                (UnityEditor.AssetDatabase.IsMainAsset(this) || UnityEditor.AssetDatabase.IsSubAsset(this)))
            {
                UnityEditor.AssetDatabase.AddObjectToAsset(iss, this);
                iss.Persist();
                UnityEditor.AssetDatabase.SaveAssets();
            }
        #endif
            return(iss);
        }
示例#3
0
        public void removeSwitch(ISwitch swt)
        {
            if (this.switches.Contains(swt))
            {
                this.switches.Remove(swt);
            }

        #if UNITY_EDITOR
            if (Application.isEditor && !Application.isPlaying &&
                (UnityEditor.AssetDatabase.IsMainAsset(this) || UnityEditor.AssetDatabase.IsSubAsset(this)))
            {
                ScriptableObject.DestroyImmediate(swt, true);
                UnityEditor.AssetDatabase.SaveAssets();
            }
        #endif
            //ScriptableObject.Destroy (swt);
        }