Esempio n. 1
0
        private T               GetGUISettingData <T>(Func <T> newGUISettings) where T : PWGUISettings
        {
            if (settingsStorage == null)
            {
                settingsStorage = new List <PWGUISettings>();
            }

            if (currentSettingCount == settingsStorage.Count)
            {
                var s = newGUISettings();

                s.windowPosition = PWUtils.Round(editorWindowRect.size / 2);
                settingsStorage.Add(s);
            }
            if (settingsStorage[currentSettingCount].GetType() != typeof(T))
            {
                //try cast, if fails create a new object
                T ret = settingsStorage[currentSettingCount] as T;
                if (ret != null)
                {
                    return(ret);
                }
                Debug.Log("type mismatch and cast fail, creating a new insatnce !");
                settingsStorage[currentSettingCount] = newGUISettings();
            }
            return(settingsStorage[currentSettingCount++] as T);
        }
Esempio n. 2
0
        public override void OnNodeProcess()
        {
            ints   = values.GetValues <int>();
            floats = values.GetValues <float>();
            vec2s  = values.GetValues <Vector2>();
            vec3s  = values.GetValues <Vector3>();
            vec4s  = values.GetValues <Vector4>();

            //check nominal type:

            fOutput  = 0;
            v2Output = Vector2.zero;
            v3Output = Vector3.zero;
            v4Output = Vector4.zero;

            if (vec4s.Count != 0)
            {
                foreach (var vec4 in vec4s)
                {
                    v4Output += vec4;
                }
                foreach (var vec3 in vec3s)
                {
                    v4Output += (Vector4)vec3;
                }
                foreach (var vec2 in vec2s)
                {
                    v4Output += (Vector4)vec2;
                }
                foreach (var flt in floats)
                {
                    v4Output += new Vector4(flt, flt, flt, flt);
                }
                foreach (var integer in ints)
                {
                    v4Output += new Vector4(integer, integer, integer, integer);
                }
                if (intify)
                {
                    v4Output = PWUtils.Round(v4Output);
                }
            }
            else if (vec3s.Count != 0)
            {
                foreach (var vec3 in vec3s)
                {
                    v3Output += (Vector3)vec3;
                }
                foreach (var vec2 in vec2s)
                {
                    v3Output += (Vector3)vec2;
                }
                foreach (var flt in floats)
                {
                    v3Output += new Vector3(flt, flt, flt);
                }
                foreach (var integer in ints)
                {
                    v3Output += new Vector3(integer, integer, integer);
                }
                if (intify)
                {
                    v3Output = PWUtils.Round(v3Output);
                }
            }
            else if (vec2s.Count != 0)
            {
                foreach (var vec2 in vec2s)
                {
                    v2Output += (Vector2)vec2;
                }
                foreach (var flt in floats)
                {
                    v2Output += new Vector2(flt, flt);
                }
                foreach (var integer in ints)
                {
                    v2Output += new Vector2(integer, integer);
                }
                if (intify)
                {
                    v2Output = PWUtils.Round(v2Output);
                }
            }
            else             //int and floats
            {
                foreach (var flt in floats)
                {
                    fOutput += flt;
                }
                foreach (var integer in ints)
                {
                    fOutput += integer;
                }
                if (intify)
                {
                    fOutput = Mathf.Round(fOutput);
                }
            }
        }